package day6;

public class CustomerBiz {
    Customer[] customers = new Customer[5];
    /**
     * 向客户数组中添加一个新的客户
     * @param name 要添加的客户名称
     * @return 如果成功添加返回true，如果数组已满则返回false
     */
    public boolean addName(String name) {
        int i = 0;
        for (; i < customers.length; i++) {
            if(customers[i] == null) break;
        }
        if(customers.length == i) return false;
        Customer newCustomer = new Customer();
        newCustomer.name = name;
        customers[i] = newCustomer;
        return true;
    }

    public void showNames() {
        System.out.println("* * * * * * * * * * *");
        System.out.println("\t\t客户姓名列表:");
        System.out.println("* * * * * * * * * * *");
        for (Customer customer : customers) {
            // customer
            if(customer == null) break;
            System.out.print(customer.name + "\t");
        }
    }

}
